Repository navigation
network-windows: Fix race condition in wait_cancellable - #1398
Conversation
b4eb78c to
cd38a0f
Compare
cd38a0f to
c971edc
Compare
|
it would likely be better if you re-used the primitives in |
8217978 to
06a51b7
Compare
| struct iiod_client_pdata { | ||
| int fd; | ||
|
|
||
| #ifdef _WIN32 |
There was a problem hiding this comment.
I'd maintain platform independence for this file. The existing architecture consists of a single header file (network.h), a core implementation file (network.c) containing cross-platform code (with some exceptions), and separate platform-specific implementation files (network-windows.c and network-unix.c).
There was a problem hiding this comment.
Modification done, let me know if it's ok now!
195e1c7 to
17a8dc7
Compare
| return -ENOMEM; | ||
| } | ||
|
|
||
| struct iio_event_sync *sync = (struct iio_event_sync*)malloc(sizeof(struct iio_event_sync)); |
There was a problem hiding this comment.
don't you need something here in case the malloc fails?
There was a problem hiding this comment.
yep, thanks.
df850cd to
7937073
Compare
|
Do you actually see a failure? or a trace from thread santizer on real application? Or is this a theoretical fix? |
Hi @rgetz, the bug is as real as it gets. I found it while using iio_info V1; sometimes the command gets stuck. After some debugging and adding logs, I discovered that the program hangs in wait_cancelable, a function called by every task that uses the socket. |
that's important to put into the commit message - how to reproduce the failure that you are seeing - so that others in the future understand the impact if they think they will see similar things, or if someone decides they need to revert this to fix something else. |
| if (!os_priv) { | ||
| goto err_close_events; | ||
| } | ||
|
|
There was a problem hiding this comment.
I think normal libiio coding style is that you don't need {} around one line statements.
There was a problem hiding this comment.
Yes, thank you so much for the advices!
ffd29fc to
5a5ce39
Compare
| free(os_priv); | ||
| goto err_close_events; | ||
| } | ||
|
|
There was a problem hiding this comment.
also similar here - it's more like other functions to move the free(os_priv); into the error/return path (at a new err_free_os_priv (or whatever your prefer), right before the existing err_close_events: label, and then in the above - you have a single goto without {}.
There was a problem hiding this comment.
Right, thanks!
Multiple threads calling wait_cancellable (e.g., one reading, one writing) were overwriting the socket's WSAEventSelect configuration. The bug appears during tests performed on ZC702 and ZC706 boards (possibly others as well) approximately 30% of the time when, for example, iio_info is executed (or any other program that creates a device context). For more details, you can refer to issue (#1402). Signed-off-by: Ruben Mujdei <ruben.mujdei@analog.com>
5a5ce39 to
72e10e3
Compare
PR Description
Multiple threads calling wait_cancellable (e.g., one reading, one writing) were overwriting the socket's WSAEventSelect configuration.
This commit adds a CriticalSection and waiter-counting logic to:
Edit:
Issue: #1402
PR Type
PR Checklist